package Runde6;

public abstract class Roboter {
	
	private static Map rMap = new Map();
	private double betriebsSt;
	private int nr;
	private Rolle rolle;
	
	/**
	 * @precondition rolle != null
	 * @postcondition create's a new robot with given params
	 */
	public Roboter(int nr, int betriebsSt, Rolle rolle) throws NonUniqueException {
		
		try {
			if (rMap.contains(nr)) {
				throw new NonUniqueException("Robot with given nr already exists!");
			}
			rMap.add(nr, this);
		} catch (InvalidTypeException e) {
			//donothing, this WON't happen (sollte vll schicker geloest werden
		}
		this.nr = nr;
		this.betriebsSt = betriebsSt;
		this.rolle = rolle;
	}

	/**
	 * @precondition betriebsSt > 0
	 * @postcondition increases betriebsSt by given value
	 */
	public void addBetriebsSt(int betriebsSt) {
		this.betriebsSt += betriebsSt;
	}
	
	/**
	 * @precondition rolle != null
	 * @postcondition Sets the robot's role to given param
	 */
	public void changeRolle(Rolle r) {
		this.rolle = r;
	}

	/**
	 * @postcondition returns the robot's betriebsSt
	 */
	public double getBetriebsSt() {
		return betriebsSt;
	}
	
	/**
	 * @postcondition returns the robot's id
	 */
	public int getId() {
		return nr;
	}
	
	/**
	 * @postcondition returns the role which is currently associated with the robot
	 */
	public Rolle getRolle() {
		return rolle;
	}
	
}